<?php

class FormCalendar extends FormControl {
	
	public static $property = array(
		'wbtype',
		'name',
		'caption',
		'x',
		'y',
		'width',
		'height',
		'disabled',
		'border',
		'visible'
	);
	
	public function __construct() { 
		parent::__construct(array(
			'wbtype' => 'Calendar',
			'x' => 0,
			'y' => 0,
			'width' => 100,
			'height' => 100
		));
	}

	/**
	 * 컨트롤 그리기 
	 * 
	 * @param WBGraphics $graphics
	 */
	public function displayControl(WBGraphics $g) {

		$xstart = $this->getOption('x');
		$ystart = $this->getOption('y');
		$width = $this->getOption('width');
		$height = $this->getOption('height');		
		$xcenter = $xstart + $width / 2;
		$xend = $xstart + $width;
		$ymiddle = $ystart + $height / 2;
		$yend = $ystart + $height;	
	
		
		if (ProjectManager::$checkWireFrame->isChecked()) { 
			$pushbutton = new FormPushButton();
			$pushbutton['caption'] = $this['caption'];
			$pushbutton['x'] = $xstart;
			$pushbutton['y'] = $ystart;
			$pushbutton['width'] = $width;
			$pushbutton['height'] = $height;
			$pushbutton['disabled'] = $this['disabled'];
			$pushbutton['readOnly'] = $this['readOnly'];
			$pushbutton['style'] = $this['style'];
			
			$pushbutton->displayControl($g);
		} else { 
			if ($this->checkStyle('border')) { 
				$xend = $xstart + $width;
				$yend = $ystart + $height;
			
				if(ProjectManager::$checkWireFrame->isChecked()) {
					$g->rect($xstart, $ystart, $width, $height, FormControl::SHADE, false, 1, WBGraphics::LINE_DASHES_2);
				} else {
					$color = ($this['disabled'] && $this['readonly']) ? FormControl::DISABLED : FormControl::EDIT;
					
					$g->rect($xstart, $ystart, $width, $height, $color, true);
					$g->line($xend - 2, $ystart, $xend - 2, $yend - 2, FormControl::EDITSHADE);
					$g->line($xstart, $yend - 2, $xend - 2, $yend - 2, FormControl::EDITSHADE);
					$g->line($xstart, $ystart, $xend - 2, $ystart, FormControl::SHADOW);
					$g->line($xstart, $ystart, $xstart, $yend - 2, FormControl::SHADOW);
				}
			} else { 
				$color = ($this['disabled']) ? FormControl::DISABLED : FormControl::EDIT;
				$g->rect($xstart, $ystart, $width, $height, $color, true);
			}
		}

	
		// Draw image
	
		if($width > 7 && $height > 11) {
			$g->image(self::$calendar, $xstart + max(0, ($width - 197) / 2) + 1,$ystart + max(0, ($height - 157) / 2) + 1,$width - 2,$height - 2);
		}

	}
	
	
	public function getProperty() { 
		return self::$property;
	}	
}


?>